#include "matrix.h"
#include "gausssolver.h"
#include "gaussseidelsolver.h"
#include <iostream>
#include <fstream>
#include <vector>

int main() {
	std::ifstream f("input.dat");
	SquareMatrix mat(0);
	f >> mat;
	int sz = mat.getDimension();
	std::vector<double> vec(sz);
	for (int i = 0; i < sz; i++) {
		f >> vec[i];
	}
	f.close();
	GaussSolver solver;
	//GaussSeidelSolver gss;
	//gss.setEps(1e-7);
	solver.setMatrix(mat);
	//gss.setMatrix(mat);
	solver.setFreeTerms(vec);
	//gss.setFreeTerms(vec);
	solver.solve();
	//gss.solve();
	if (solver.state() == GaussSolver::ssNotSolvable) {
		std::cout << "No solution can be found\n";
	} else {
		std::vector<double> sol = solver.solution();
		std::cout << "Solution (by Gauss):\n";
		for (int i = 0, cnt = sol.size(); i < cnt; i++) {
			std::cout << sol[i] << " ";
		}
		std::cout << "\n";
	}
	/*if (gss.state() == GaussSolver::ssNotSolvable) {
		std::cout << "No solution can be found\n";
	} else {
		std::vector<double> sol = gss.solution();
		std::cout << "Solution (by Gauss-Seidel):\n";
		for (int i = 0, cnt = sol.size(); i < cnt; i++) {
			std::cout << sol[i] << " ";
		}
		std::cout << "\n";
	}*/
	return 0;
}
